/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.ec.search.entity.Keyword
   Module Description   :

   Date Created      : 2009/12/3
   Original Author   : jeff.ma
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.ec.search.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.GenericGenerator;

import com.yaodian100.core.common.entity.BaseEntity;

/**
 * @author jeff.ma
 * 
 */
@Entity
@Table(name = "EC_SEARCH_KEYWORD")
public class Keyword extends BaseEntity {

	/** serialVersionUID */
	private static final long serialVersionUID = 5363732377534935278L;
	@Id
	@GeneratedValue(generator = "gen_uuid")
	@GenericGenerator(name = "gen_uuid", strategy = "uuid")
	@Column(name = "WORD_UUID", length = 32)
	private String uuid;
	@Column(name = "CATEGORY_ID")
	private Long categoryId;
	@Column(name = "CATEGORY_LEVEL", length = 5)
	private String categoryLevel;
	@Column(name = "CATEGORY_PATH", length = 100)
	private String categoryPath;
	@Column(name = "WORD_BODY", length = 500)
	private String word;

	/** default constructor */
	public Keyword() {
	}

	/**
	 * @return the uuid
	 */
	public String getUuid() {
		return uuid;
	}

	/**
	 * @param uuid the uuid to set
	 */
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	/**
	 * @return the categoryLevel
	 */
	public String getCategoryLevel() {
		return categoryLevel;
	}

	/**
	 * @param categoryLevel the categoryLevel to set
	 */
	public void setCategoryLevel(String categoryLevel) {
		this.categoryLevel = categoryLevel;
	}

	/**
	 * @return the categoryPath
	 */
	public String getCategoryPath() {
		return categoryPath;
	}

	/**
	 * @param categoryPath the categoryPath to set
	 */
	public void setCategoryPath(String categoryPath) {
		this.categoryPath = categoryPath;
	}

	/**
	 * @return the categoryId
	 */
	public Long getCategoryId() {
		return categoryId;
	}

	/**
	 * @param categoryId the categoryId to set
	 */
	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	/**
	 * @return the word
	 */
	public String getWord() {
		return word;
	}

	/**
	 * @param word the word to set
	 */
	public void setWord(String word) {
		if (word != null) {
			word = StringUtils.replace(word, "\r\n", "\n");
		}
		this.word = word;
	}

	/**
	 * @return the word
	 */
	public String[] getWords() {
		if (word != null) {
			return StringUtils.split(word, "\n");
		}
		return new String[] {};
	}

	/**
	 * @param word the word to set
	 */
	public void setWords(String[] words) {
		if (words != null) {
			this.word = StringUtils.join(words, "\\n");
		}
	}
}
